package main

import (
	"fmt"
	"net"
	"server/dao"
	"time"
)

func main() {
	listen, err := net.Listen("tcp", "localhost:8888")
	if err != nil{
		fmt.Println(err)
		return
	}
	defer listen.Close()

	initPool("localhost", 16, time.Second * 200)
	dao.NewUserDao(pool)

	for {
		fmt.Println("wait client connect.......")

		conn, err := listen.Accept()
		if err != nil {
			fmt.Println(err)
			return
		}
		fmt.Println("\tclient connect success....")
		// 处理逻辑
		p :=  &Processor{
			Conn: conn,
		}
		go p.Process()
	}
}